package org.example.application;

import com.github.pagehelper.PageInfo;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.example.domain.model.entity.url.UrlShortener;
import org.example.domain.model.entity.url.req.UrlShortenerCreateReq;
import org.example.domain.model.entity.url.req.UrlShortenerSelectReq;
import org.example.domain.model.entity.url.req.UrlShortenerUpdateReq;
import org.example.domain.model.entity.url.resp.QueryGroupByCountResp;
import org.example.domain.model.entity.url.resp.UrlShortenerCreateResp;
import org.example.domain.model.service.UrlShortenerDomainService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
@Slf4j
public class UrlShortenerService {
    private final UrlShortenerDomainService urlShortenerDomainService;
    public UrlShortenerCreateResp createUrlShortener(UrlShortenerCreateReq urlshortenerCreateReq) {
        return urlShortenerDomainService.createUrlShortener(urlshortenerCreateReq);
    }

    public void restoreUrl(String shortUri, ServletRequest request, ServletResponse response) {
        urlShortenerDomainService.restoreUrl(shortUri, request, response);
    }

    public void updateUrlShortener(UrlShortenerUpdateReq urlShortenerUpdateReq) {
        urlShortenerDomainService.updateUrlShortener(urlShortenerUpdateReq);
    }

    public PageInfo<UrlShortener> selectByPage(UrlShortenerSelectReq urlShortenerSelectReq) {
        return urlShortenerDomainService.selectByPage(urlShortenerSelectReq);
    }

    public List<QueryGroupByCountResp> queryGroupByCount(List<String> gidList) {
        return urlShortenerDomainService.queryGroupByCount(gidList);
    }
}
